package com.whmnx.chitchat.adapter;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.classic.adapter.BaseAdapterHelper;
import com.classic.adapter.CommonRecyclerAdapter;
import com.whmnx.chitchat.R;
import com.whmnx.chitchat.bean.UserBean;
import com.whmnx.chitchat.ui.chat.FriendInfoActivity;
import com.whmnx.chitchat.utils.ImageUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * author : huang
 * date   : 2020/7/27 0027 17:31
 * version: 1.0
 * @author Administrator
 */
public class UserAdpter3 extends CommonRecyclerAdapter<UserBean> {
    private Context context;
    private List<Boolean> alreadyLikeList = new ArrayList<>();
    private ImageView view;


    public UserAdpter3(Context context) {
        super(context, R.layout.item_list_user);
        this.context = context;
    }


    @Override
    public void onUpdate(BaseAdapterHelper helper, UserBean item, int position) {
       /* if (TextUtils.isEmpty(item.getUserNick())){
            helper.setText(R.id.tv, (String) item.NickName);
        }else {
            helper.setText(R.id.tv, (String) item.getUserNick());
        }*/

        if (TextUtils.isEmpty(item.Remarks)){
            helper.setText(R.id.tv, (String) item.UserNickName);
        }else {
            if (item.Remarks.equals(item.UserNickName)){
                helper.setText(R.id.tv, (String) item.UserNickName);
            }else {
                helper.setText(R.id.tv, (String) item.Remarks + "(" + item.UserNickName + ")");
            }
        }

        ImageUtil.setImage(helper.getView(R.id.cv_user),item.getHeadImg());
        helper.getView(R.id.cv_user).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("result", item);
                intent.putExtra("type", 2);
                if (TextUtils.isEmpty(item.getUserId())){
                    intent.putExtra("userId", item.UserID);
                }else {
                    intent.putExtra("userId", item.getUserId());
                }

                intent.setClass(context, FriendInfoActivity.class);
                context.startActivity(intent);
            }
        });
    }
}
